package com.ikas.ai.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 是否枚举
 */
@AllArgsConstructor
public enum YesNoEnum implements BaseEnum<YesNoEnum, Integer> {

    N(0, "否", Boolean.FALSE),
    Y(1, "是", Boolean.TRUE),

    ;

    private final Integer code;
    private final String name;

    @Getter
    private final Boolean flag;

    @Override
    public Integer code() {
        return code;
    }

    @Override
    public String desc() {
        return name;
    }

    /**
     * 是否
     */
    public static boolean yes(Integer code) {
        return Y.code.equals(code);
    }

    /**
     * 是否
     */
    public static Integer yes(Boolean flag) {
        return Y.flag.equals(flag) ? Y.code : N.code;
    }
}
